import Blockly from 'blockly/core'
import 'blockly/python_compressed'
import 'blockly/blockly_compressed'
import 'blockly/blocks_compressed'

Blockly.Blocks.function_bin = {
  init: function () {
    this.appendValueInput('int').setCheck('Number').appendField('bin')
    this.setInputsInline(false)
    this.setOutput(true, 'Number')
    this.setColour(230)
    this.setTooltip('')
    this.setHelpUrl('')
  }
}

Blockly.Python.function_bin = function (block) {
  const valueInt = Blockly.Python.valueToCode(
    block,
    'int',
    Blockly.Python.ORDER_ATOMIC
  )
  const code = 'bin(' + valueInt + ')'
  return [code, Blockly.Python.ORDER_NONE]
}

export default Blockly
